package com.mine.springmvc.thread;

// 测试线程插队

public class TestJoin implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println("线程vip来了"+i);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }


    public static void main(String[] args) throws InterruptedException {
        TestJoin testJoin = new TestJoin();
        //启动我们的线程
        Thread thread = new Thread(testJoin);
        thread.start();

        //主线程
        for (int i = 0; i < 1000; i++) {
            if(i == 200){
                thread.join(); //thread线程开始插队,等他执行完主线程再执行
            }
            System.out.println("main"+i);
        }


    }
}
